﻿using System;
using MathNet.Numerics.LinearAlgebra;

namespace GridRayTracer
{
  public class HitResult
  {
    public HitResult(Ray ray, SceneObject sceneObject, Vector hitPoint, Vector normal)      
    {
      Ray = ray;
      SceneObject = sceneObject;
      HitPoint = hitPoint;
      Normal = normal;      
    }
    
    public readonly Ray Ray;
    public readonly SceneObject SceneObject;
    
    public Ray ReflectedRay
    {
      get
      {
        var dir = -2 * Normal.ScalarMultiply(Ray.Direction) * Normal + Ray.Direction;
        return new Ray(HitPoint + dir.Scale(1e-5), dir);
      }
    }
    
    public Vector HitPoint
    {
      get;
      set;
    }
    
    public Vector Normal 
    {
      get;
      set;
    }
  }
}
